var express = require('express');
var router = express.Router();
var mysqlquery = require("../db/mysql.js");

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('login.html');
});
router.post('/login',async (req,res)=>{
   let {tel="",pass=""} = await req.body;
 
    let sql = `select * from users where username = ${tel} and password = ${pass}`;

   let [flag,data] = await mysqlquery(sql);
  console.log(flag,data)
   if(flag)
   {
     res.send("登录成功");
   }
   else{
     res.send("登录失败");
   }
})
module.exports = router;
